<?php 
require_once(dirname(__FILE__).'/inc/config.inc.php');IsModelPriv('goods');
$filename="goods_".date("YmdHis");
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:attachment;filename=".$filename.".xls");
//参数
$adcode = isset($areaid) ? $areaid : ''; //区域
$typeid = isset($typeid) ? $typeid : ''; //咨询点
$repairid = isset($repairid) ? $repairid : ''; //地区代码
$jindu = isset($jindu) ? $jindu : '';
?>

<table border="1">
            <thead>
              <tr>
              <th>序号 </th>
			  <th>省 </th>
			  <th>市 </th>
			  <th>区 </th>
               <th>报修单位 </th>
                <th>联系人 </th>
                <th>联系方式 </th>
                <th>设备类型 </th>
                <th>序列号 </th>
                <th>故障描述 </th>
                <th>维修进度 </th>
                <th>维修费用</th>
                <th>报修时间</th>
				<th>客服联系备注</th>
                <th>完修时间</th>
				<th>维修概要</th>
                <th>完修工程师</th>
                <th>备注</th>
              </tr>
            </thead>
            <tbody>
              <?php 

	//设置sql
$sql_order = "SELECT f.*,t.dataname as typename,j.dataname as jinduname,u.truename as truename,u.school as school,u.sheng as sheng,u.shi as shi,u.qu as qu,u.address as address,u.mobile as mobile FROM `#@__order` as f
		left join `#@__user`  as u on u.id=f.uid
		left join `#@__cascadedata`  as t on t.datavalue=f.apply_type  
		left join `#@__cascadedata`  as j on j.datavalue=f.jindu  
		WHERE t.datagroup='type'  AND j.datagroup='jindu'  AND   f.delstate='' ";
	if(!empty($typeid)) $sql_order .= " AND f.apply_type='$typeid'  ";
	if(!empty($repairid)) $sql_order .= " AND f.repairid='$repairid'  ";
	if(!empty($adcode)) $sql_order .= " AND f.adcode='$adcode'  ";
	if(!empty($jindu)) $sql_order .= " AND f.jindu='$jindu'  ";
	$sql_order.="  order by f.id desc ";
 	$dosql->Execute($sql_order);
while($result=$dosql->GetArray()){
	$truename=$result['truename'];
	$school=$result['school'];
	$mobile=$result['mobile'];
	$typename=$result['typename'];
	$jindu=$result['jinduname'];
	//获取客户的信息 
	$post_time=date("Y-m-d H:i:s",$result['post_time']);
	$over_time=$result['over_time']>0 ? date("Y-m-d H:i:s",$result['over_time']) : "";
	//完修工程师
	$order_id=$result['id'];
	$m_array=$dosql->GetOne("select manageid from `#@__order_log` where orderid='$order_id' and jindu='5' ");
	if( is_array($m_array) && isset($m_array['manageid']) ){
		$manage_id=$m_array['manageid'];
		$manage_array=$dosql->GetOne("select company,truename from `#@__manage` where id='$manage_id' ");
		$manage_name=$manage_array['company']."-".$manage_array['truename'];
	}else{
		$manage_name="";
	}


?>
              <td><?php echo $result['id'];?></td>
			  <td><?php echo $result['sheng'];?></td>
			  <td><?php echo $result['shi'];?></td>
			  <td><?php echo $result['qu'];?></td>
              <td><?php echo $school;?></td>
              <td><?php echo $truename;?></td>
			  <td><?php echo $mobile;?></td>
			  <td><?php echo $typename?></td>
			  <td><?php echo $result['device_num']?></td>
			  <td><?php echo $result['content']?></td>
			  
			  <td><?php echo $jindu?></td>
              <td><span style="color:#F00"><?php echo $result['fee'];?></span></td>
              <td><?php echo $post_time;?></td>
			  <td><?php echo $result['remark']?></td>
              <td><?php echo $over_time;?></td>
			  <td><?php echo $result['over_remark']?></td>
              <td><?php echo $manage_name?></td>
              <td>&nbsp;</td>
            </tr>
            <?php 

} 
?>
              </tbody>
</table>